package com.huadi.bili_hot.controller;

import com.huadi.bili_hot.entity.DailyPost;
import com.huadi.bili_hot.entity.HotInfo;
import com.huadi.bili_hot.entity.TimeAndView;
import com.huadi.bili_hot.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private DailyPostService dailyPostService;
    @Autowired
    private HotInfoService hotInfoService;
    @Autowired
    private TimeAndViewService timeAndViewService;

    @RequestMapping("/")
//    @ResponseBody
    public String getAll(ModelMap modelMap) {
        List<TimeAndView> timeAndViews = timeAndViewService.getTimeAndView();
        List<HotInfo> hotInfos = hotInfoService.getHotInfo();
        DailyPost dailyPost = dailyPostService.getDailyPost();
        modelMap.put("dailyPost", dailyPost);
        modelMap.put("TaV", timeAndViews);
        modelMap.put("hot", hotInfos);
        return "index";
    }
}
